package game.evaluator;

import game.rule.MorrisGameRule;
import game.util.StringUtils;

public class MorrisGameEvaluatorImpl implements IMorrisGameEvaluator {

	@Override
	public int estimateOpening(String board) {
		int w = StringUtils.charCount(board, 'W'), b = StringUtils.charCount(
				board, 'B');
		return w - b;
	}

	@Override
	public int estimateMidgameEndgame(String board) {
		int w = StringUtils.charCount(board, 'W'), b = StringUtils.charCount(
				board, 'B');
		if (b <= 2) {
			return 10000;
		} else if (w <= 2) {
			return -10000;
		} else if (MorrisGameRule.generateBlackMovesMidgameEndgame(board)
				.size() == 0) {
			return 10000;
		}
		return 1000 * (w - b)
				- MorrisGameRule.generateBlackMovesMidgameEndgame(board).size();
	}

}
